import 'package:high_help_apps/common/entities/entities.dart';
import 'package:high_help_apps/common/entities/user/user_login_request_entity.dart';
import 'package:high_help_apps/common/entities/user/user_profile_response_entity.dart';
import 'package:high_help_apps/common/entities/user/user_register_request_entity.dart';
import 'package:high_help_apps/common/entities/user/user_register_response_entity.dart';
import 'package:high_help_apps/common/utils/http.dart';

/// FileName: user
/// Author: admin
/// Date: 2021-07-30 16:59
/// Description: 用户相关api

class UserAPI {

  /// 登录
  static Future login({
    UserLoginRequestEntity? params
  }) async {
    var response = await HttpUtil().post(
      '/user/login',
      data: params?.toJson()
    );
    return UserLoginResponseEntity().fromJson(response);
  }

  /// 注册
  static Future register({
    UserRegisterRequestEntity? params
  }) async {
    var response = await HttpUtil().post(
        '/user',
        data: params?.toJson()
    );
    return UserRegisterResponseEntity().fromJson(response);
  }

  /// 获取个人资料
  static Future getProfile() async {
    var response = await HttpUtil().get(
      '/user/c_user'
    );

    return UserProfileResponseEntity().fromJson(response);
  }

}
